package com.nbsaas.nbmall.shop.rest.convert;

import com.haoxuer.discover.data.enums.StoreState;
import com.nbsaas.nbmall.shop.api.domain.simple.ShopSimple;
import com.nbsaas.nbmall.shop.data.entity.Shop;
import com.haoxuer.discover.data.rest.core.Conver;
import com.nbsaas.nbmall.shop.data.enums.AuditState;
import com.nbsaas.nbmall.shop.data.enums.ShopState;

public class ShopSimpleConvert implements Conver<ShopSimple, Shop> {


    @Override
    public ShopSimple conver(Shop source) {
        ShopSimple result = new ShopSimple();
        if (source.getStoreState() == null) {
            source.setStoreState(StoreState.normal);
        }
        if (source.getAuditState() == null) {
            source.setAuditState(AuditState.wait);
        }
        if (source.getShopState() == null) {
            source.setShopState(ShopState.normal);
        }

        result.setId(source.getId());
        if (source.getArea() != null) {
            result.setArea(source.getArea().getId());
        }
        result.setSummary(source.getSummary());
        result.setAddress(source.getAddress());
        if (source.getCreator() != null) {
            result.setCreator(source.getCreator().getId());
        }
        result.setStoreState(source.getStoreState());
        result.setDishDeliveryMethod(source.getDishDeliveryMethod());
        result.setContact(source.getContact());
        if (source.getBoss() != null) {
            result.setBossName(source.getBoss().getName());
        }
        result.setTransport(source.getTransport());
        result.setTakeaway(source.getTakeaway());
        result.setBaseSaleNum(source.getBaseSaleNum());
        result.setAddDate(source.getAddDate());
        if (source.getChannel() != null) {
            result.setUrl(source.getChannel().getUrl());
        }
        result.setPerMoney(source.getPerMoney());
        result.setTakeawayRate(source.getTakeawayRate());
        result.setName(source.getName());
        if (source.getShopCatalog() != null) {
            result.setShopCatalogName(source.getShopCatalog().getName());
        }
        result.setDishSaleNum(source.getDishSaleNum());
        result.setMealSubject(source.getMealSubject());
        result.setDishAmount(source.getDishAmount());
        if (source.getBoss() != null) {
            result.setBoss(source.getBoss().getId());
        }
        result.setDiscountNum(source.getDiscountNum());
        result.setNote(source.getNote());
        if (source.getCity() != null) {
            result.setCity(source.getCity().getId());
        }
        result.setDeliveryMethod(source.getDeliveryMethod());
        result.setDistance(source.getDistance());
        result.setDeliveryTime(source.getDeliveryTime());
        result.setShopState(source.getShopState());
        if (source.getChannel() != null) {
            result.setChannel(source.getChannel().getId());
        }
        result.setSortScore(source.getSortScore());
        result.setAuditState(source.getAuditState());
        result.setScore(source.getScore());
        result.setBeginTime(source.getBeginTime());
        result.setTel(source.getTel());
        result.setCashRate(source.getCashRate());
        result.setLat(source.getLat());
        result.setBalanceMethod(source.getBalanceMethod());
        result.setReceivingTime(source.getReceivingTime());
        if (source.getExt() != null) {
            result.setExt(source.getExt().getId());
        }
        result.setStartPrice(source.getStartPrice());
        result.setHallFood(source.getHallFood());
        result.setThumbnail(source.getThumbnail());
        result.setLng(source.getLng());
        result.setProductNum(source.getProductNum());
        result.setCashModel(source.getCashModel());
        if (source.getTradeAccount() != null) {
            result.setAmount(source.getTradeAccount().getAmount());
        }
        result.setSaleNum(source.getSaleNum());
        result.setEatOutTime(source.getEatOutTime());
        result.setEndTime(source.getEndTime());
        result.setFreightSubject(source.getFreightSubject());
        result.setFoodModel(source.getFoodModel());
        result.setAutoOrder(source.getAutoOrder());
        result.setProductModel(source.getProductModel());
        result.setRefundNum(source.getRefundNum());
        result.setServiceModel(source.getServiceModel());
        result.setFreight(source.getFreight());
        result.setSelfRate(source.getSelfRate());
        result.setStaffNum(source.getStaffNum());
        if (source.getProvince() != null) {
            result.setProvince(source.getProvince().getId());
        }
        result.setReceivingMode(source.getReceivingMode());
        result.setTransportTime(source.getTransportTime());
        result.setHallFoodRate(source.getHallFoodRate());
        result.setSortNum(source.getSortNum());
        result.setLogo(source.getLogo());
        if (source.getShopCatalog() != null) {
            result.setShopCatalog(source.getShopCatalog().getId());
        }

        result.setFreightSubjectName(source.getFreightSubject() + "");
        result.setAuditStateName(source.getAuditState() + "");
        result.setReceivingModeName(source.getReceivingMode() + "");
        result.setShopStateName(source.getShopState() + "");
        result.setMealSubjectName(source.getMealSubject() + "");
        result.setStoreStateName(source.getStoreState() + "");
        return result;
    }
}
